package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MinioYml.class)
public class MinioConfiguration {
    @Autowired
    private MinioYml minioYml;

    @Bean
    public MinioClient minioClient() {
        /*String endpoint = minioYml.getEndpoint();
        String accessKey = minioYml.getAccessKey();
        String secretKey = minioYml.getSecretKey();
        String bucketName = minioYml.getBucketName();
        System.out.println("endpoint = " + endpoint);
        System.out.println("accessKey = " + accessKey);
        System.out.println("secretKey = " + secretKey);
        System.out.println("bucketName = " + bucketName);
        MinioClient.builder().endpoint(endpoint);*/
        return MinioClient.builder()
                .endpoint(minioYml.getEndpoint())
                .credentials(minioYml.getAccessKey(), minioYml.getSecretKey())
                .build();
//        return null;
    }
}
